package net.lab1024.sa.admin.module.system.user.controller;

import net.lab1024.sa.admin.module.system.user.domain.form.UserQueryForm;
import net.lab1024.sa.admin.module.system.user.domain.vo.UserVO;
import net.lab1024.sa.admin.module.system.user.service.UserService;
import net.lab1024.sa.common.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.common.common.domain.ResponseDTO;
import net.lab1024.sa.common.common.domain.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;

/**
 * 用户表 Controller
 *
 * @Author jabari
 * @Date 2023-06-12 14:10:13
 * @Copyright 51dev.cn
 */

@RestController
@Api(tags = "")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("分页查询 @author jabari")
    @PostMapping("/user/queryPage")
    public ResponseDTO<PageResult<UserVO>> queryPage(@RequestBody @Valid UserQueryForm queryForm) {
        return ResponseDTO.ok(userService.queryPage(queryForm));
    }

    @ApiOperation("批量删除 @author jabari")
    @PostMapping("/user/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return userService.batchDelete(idList);
    }

    @ApiOperation("单个删除 @author jabari")
    @GetMapping("/user/delete/{userId}")
    public ResponseDTO<String> batchDelete(@PathVariable Integer userId) {
        return userService.delete(userId);
    }
}
